home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Newbie: How to put a byte to a000:0001 or more?
- Date: 29 Mar 1996 21:47:26 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4jihteINNodr@keats.ugrad.cs.ubc.ca>
- References: <4jhur8$995@sanjuan.islandnet.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4jhur8$995@sanjuan.islandnet.com>,
- Abram Hindle <abehind@islandnet.com> wrote:
- >Ok I'm a newbie to C and to Assembler.
- > I need help with finding out how in assembler or in c
- >I can put (quickly) a byte in the a000:0000+ address to
- >draw a pixel on the screen?
-
- The ':' character is used in the C language to introduce the width of a bit
- field:
-
- struct foo {
- unsigned x : 3;
- y : 4;
- };
-
-
- >I'm doing this on a IBM compatiable in VGA mode (13h)
- >I've done something like so:
- >void putpixel(int x, int y, char col)
- >{
- >unsigned int pos;
- >pos=x+(y*319)
-
- Surely you mean 320! Duh!
-
- 319 is the product of two primes, 11 and 29. Not a likely candidate for the
- number of pixels in a scanline.
-
- >asm {
- >
- > mov al,[col]/*al = colour*/
- > mov ax,[pos]/*ax = position*/
-
- Duh, a move to ax clobbers al. The ax register is made up of ah and al.
-
- Please don't post obsolete 16-bit assembly code to a newsgroup that
- doesn't even have anything to do with assembly language programming!
-
- It is annoying.
-
- > mov DI,ax /*move ax to di*/
- > mov ax,[VGA]/*copies 0a000h to ax i've defined it*/
-
- That is a redundant instruction that even a Microsoft C++ compiler would
- eliminate. You first move something to ax, and then you move from ax to
- something else, and then you clobber ax again, meaning that the original move
- to ax was completely useless.
-
- > mov es,ax /*moves that to es*/
- > mov [ES:DI],al /*Put in Memory al(colour)*/
-
- The color in al that you clobbered in line 2?
-
-
- > }
- >}
- >
- >and it does nothing! So could you guys help? I really need it,
-
- Go to comp.lang.asm.x86. This is a C language newsgroup.
-
- >BGIs are to slow and so is using int 10h.
-
- How would you know?
- --
-
-